﻿using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using K9Nano.Authorization;

namespace K9Admin.Remoting
{
    public class RemoteRoleResourceStore: IRoleResourceStore
    {
        protected readonly ApiResourceService.ApiResourceServiceClient Client;

        public RemoteRoleResourceStore(ApiResourceService.ApiResourceServiceClient client)
        {
            Client = client;
        }

        public ValueTask<IReadOnlyList<string>> GetResourcesAsync(string api, IEnumerable<string> roles, CancellationToken cancellation)
        {
            throw new System.NotImplementedException();
        }

        public async ValueTask<IReadOnlyList<string>> GetRolesInResourceAsync(string api, string resource, CancellationToken cancellation)
        {
            var result = await Client.GetRolesInResourceAsync(new GetRolesInResourceRequest
            {
                Api = api,
                Resource = resource
            }, cancellationToken: cancellation);

            return result.Roles;
        }

        public ValueTask RemoveRoleFromResourcesAsync(string api, string resource, IEnumerable<string> roles, CancellationToken cancellation)
        {
            throw new System.NotImplementedException();
        }

        public ValueTask AddRoleToResourcesAsync(string api, string role, IEnumerable<string> resources, CancellationToken cancellation)
        {
            throw new System.NotImplementedException();
        }
    }
}